package com.ruoyi.project.channel.uxInfo.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.channel.uxInfo.domain.UxInfo;
import com.ruoyi.project.channel.uxInfo.service.IUxInfoService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 第三方信息操作处理
 * 
 * @author CAIN
 * @date 2020-02-23
 */
@Controller
@RequestMapping("/channel/uxInfo")
public class UxInfoController extends BaseController
{
    private String prefix = "channel/uxInfo";
	
	@Autowired
	private IUxInfoService uxInfoService;
	
	@RequiresPermissions("channel:uxInfo:view")
	@GetMapping()
	public String uxInfo()
	{
	    return prefix + "/uxInfo";
	}
	
	/**
	 * 查询第三方列表
	 */
	@RequiresPermissions("channel:uxInfo:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(UxInfo uxInfo)
	{
		startPage();
        List<UxInfo> list = uxInfoService.selectUxInfoList(uxInfo);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出第三方列表
	 */
	@RequiresPermissions("channel:uxInfo:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(UxInfo uxInfo)
    {
    	List<UxInfo> list = uxInfoService.selectUxInfoList(uxInfo);
        ExcelUtil<UxInfo> util = new ExcelUtil<UxInfo>(UxInfo.class);
        return util.exportExcel(list, "uxInfo");
    }
	
	/**
	 * 新增第三方
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存第三方
	 */
	@RequiresPermissions("channel:uxInfo:add")
	@Log(title = "第三方", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(UxInfo uxInfo)
	{		
		return toAjax(uxInfoService.insertUxInfo(uxInfo));
	}

	/**
	 * 修改第三方
	 */
	@GetMapping("/edit/{uxId}")
	public String edit(@PathVariable("uxId") Long uxId, ModelMap mmap)
	{
		UxInfo uxInfo = uxInfoService.selectUxInfoById(uxId);
		mmap.put("uxInfo", uxInfo);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存第三方
	 */
	@RequiresPermissions("channel:uxInfo:edit")
	@Log(title = "第三方", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(UxInfo uxInfo)
	{		
		return toAjax(uxInfoService.updateUxInfo(uxInfo));
	}
	
	/**
	 * 删除第三方
	 */
	@RequiresPermissions("channel:uxInfo:remove")
	@Log(title = "第三方", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(uxInfoService.deleteUxInfoByIds(ids));
	}
	
}
